package com.mxpio.erp.workshop.service.impl;

import com.mxpio.erp.common.workshop.entity.MaterialKittingAnalysisHistory;
import com.mxpio.erp.common.workshop.service.MaterialKittingAnalysisHistoryService;
import com.mxpioframework.jpa.JpaUtil;
import com.mxpioframework.jpa.query.Criteria;
import com.mxpioframework.jpa.query.Order;
import com.mxpioframework.system.service.impl.BaseServiceImpl;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;


@Service
public class MaterialKittingAnalysisHistoryServiceImpl extends BaseServiceImpl<MaterialKittingAnalysisHistory> implements MaterialKittingAnalysisHistoryService {
    @Override
    @Transactional
    public MaterialKittingAnalysisHistory lastOne() {
        Criteria criteria = Criteria.create();
        criteria.addOrder(new Order("createTime",true));
        List<MaterialKittingAnalysisHistory> list = JpaUtil.linq(MaterialKittingAnalysisHistory.class).where(criteria).list();
        if (!list.isEmpty()){
            return list.get(0);
        }
        return null;
    }
}
